defence mechanism

noun
1.
(psychoanal) a usually unconscious mental process designed to reduce the anxiety, shame, etc, associated with instinctive desires
2.
(physiol) the protective response of the body against disease organisms